﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace PushManager.Web.Controllers
{
    public class LogController : Controller
    {
        // GET: Log
        public ActionResult Index(string filepath)
        {
            if (string.IsNullOrEmpty(filepath))
                filepath = "~/server_traces.txt";
            var serverPath = Server.MapPath(filepath);

            List<string> contents = new List<string>();
            StringBuilder sb = new StringBuilder();
            using (var fs = new FileStream(serverPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                StreamReader reader = new StreamReader(fs);
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    contents.Add(line);
                }
            }
            return View(contents);
        }
    }
}